// -*-mode:c++; coding:utf-8-*-

#ifndef _XBASE_UUID_HPP_
#define _XBASE_UUID_HPP_

#include "atomic.h"

namespace xbase
{
	//
	// use as follows:
	// 
	// struct sstable_tag {};
	// typedef boost::details::pool::singleton_default
	//                  < uuid<sstable_tag> > sstable_uuid;
	// int id = sstable_uuid::instance().get();
	
	template<typename TagT>
	class uuid
	{
	public:
		typedef TagT tag;

	public:
		uuid() {
			atomic_set(&m_uuid, 0);
		}
		
		unsigned int get() {
			return atomic_inc_return(&m_uuid);
		}

	private:
		atomic_t m_uuid;
	};

} // namespace xbase

#endif	// _XBASE_UUID_HPP_
